home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
090
/
cmln0386.arc
/
CROSSTH5.LTG
< prev
next >
Wrap
Text File
|
1986-03-03
|
896b
|
36 lines
Listing 5.
Example of dynamic open arrays in Pascal MT+
Program Average;
VAR
Vector1 : ARRAY [1..10] OF REAL;
Vector2 : ARRAY [10.100] OF REAL;
PROCEDURE FillVector(VAR A : ARRAY [LOW..HI : INTEGER] OF REAL);
VAR I : INTEGER;
BEGIN
FOR I := LOW TO HI DO
A[I] := I;
END; (* FillVector *)
PROCEDURE GetMean(VAR A : ARRAY [LOW..HI : INTEGER] OF REAL;
VAR Mean : REAL);
VAR I : INTEGER;
BEGIN
Mean := 0; (* Initialize result *)
FOR I := LOW TO HI DO
Mean := Mean + A[I];
Mean := Mean / (HI - LOW + 1);
END; (* GetMean *)
èBEGIN
FillVector(Vector1); GetMean(Vector1); WRITELN('Mean 1 = ',Mean);
FillVector(Vector2); GetMean(Vector2); WRITELN('Mean 2 = ',Mean);
END.